
#include "UInt32.h"

#include <math.h>

// DEBUG.
#include "Debug.h"

using namespace Riccsson::System;

REGISTER_CLASS_CPP(UInt32)
{

}

//---------------------------------------------------------------------------------------
int UInt32::CompareTo(int* value)
{
	return _internalUInt32 > *value ? 1 : _internalUInt32 < *value ? -1 : 0;
}
//---------------------------------------------------------------------------------------
int UInt32::CompareTo(object* value)
{
	if (!(instanceof(value, UInt32)))
		return false;

	return ((UInt32*)value)->_internalUInt32 == _internalUInt32;
}
//---------------------------------------------------------------------------------------
bool UInt32::Equals(int* obj)
{
	return _internalUInt32 == *obj;
}
//---------------------------------------------------------------------------------------
bool UInt32::Equals(object* obj)
{
	if (!(instanceof(obj, UInt32)))
		return false;

	return ((UInt32*)obj)->_internalUInt32 == _internalUInt32;
}
//---------------------------------------------------------------------------------------
int UInt32::GetHashCode()
{
	return _internalUInt32;
}
//---------------------------------------------------------------------------------------
TypeCode UInt32::GetTypeCode()
{
	throw;
}
//---------------------------------------------------------------------------------------
// Static.
int UInt32::Parse(string* s)
{
	throw;
}
//---------------------------------------------------------------------------------------
// Static.
int UInt32::Parse(string* s, IFormatProvider* provider)
{
	throw;
}
//---------------------------------------------------------------------------------------
// Static.
int UInt32::Parse(string* s, Globalization::NumberStyles style)
{
	throw;
}
//---------------------------------------------------------------------------------------
// Static.
int UInt32::Parse(string* s, Globalization::NumberStyles style, IFormatProvider* provider)
{
	throw;
}
//---------------------------------------------------------------------------------------
GC_PTR<Riccsson::System::string> UInt32::ToString()
{
	bool isNegative(false);
	if(_internalUInt32 < 0)
	{
		isNegative = true;
		_internalUInt32 = -_internalUInt32;
	}

	int length = (int) log10((double) _internalUInt32);
	char* intToString = new char[length + 2];

	int x = _internalUInt32;
	int i = (int) log10((double) x);
	while(x > 0)
	{
		intToString[i] = (x % 10) + '0';
		x = x / 10;
		i = i - 1;
	}

	intToString[length + 1] = '\0';

	if(isNegative)
	{
		char* intToString2 = new char[length + 2 + 1];
		for(int i = 1; (intToString2[i] = intToString[i-1]) != '\0'; i++);
		intToString2[0] = '-';
		delete intToString;
		intToString = intToString2;
	}

	GC_PTR<string> output( new string(intToString) );

	delete intToString;
	intToString = null;

	return output;
}
//---------------------------------------------------------------------------------------
GC_PTR<Riccsson::System::string> UInt32::ToString(IFormatProvider* provider)
{
	throw;
}
//---------------------------------------------------------------------------------------
GC_PTR<Riccsson::System::string> UInt32::ToString(string* format)
{
	throw;
}
//---------------------------------------------------------------------------------------
GC_PTR<Riccsson::System::string> UInt32::ToString(const char* format)
{
	throw;
}
//---------------------------------------------------------------------------------------
GC_PTR<Riccsson::System::string> UInt32::ToString(string* format, IFormatProvider* provider)
{
	throw;
}
//---------------------------------------------------------------------------------------
// Static.
bool UInt32::TryParse(string* s, int out result)
{
	throw;
}
//---------------------------------------------------------------------------------------
// Static.
bool UInt32::TryParse(string* s, Globalization::NumberStyles style, IFormatProvider* provider, int out result)
{
	throw;
}




//----------------------------------------------------------------------------
// +
UInt32 UInt32::operator+ ( const UInt32 value )
{
	return UInt32(this->_internalUInt32 + value._internalUInt32);
}

//----------------------------------------------------------------------------
// -
UInt32 UInt32::operator- ( const UInt32 value )
{
	return UInt32(this->_internalUInt32 - value._internalUInt32);
}

//----------------------------------------------------------------------------
// *
UInt32 UInt32::operator* ( const UInt32 value )
{
	return UInt32(this->_internalUInt32 * value._internalUInt32);
}

//----------------------------------------------------------------------------
// /
UInt32 UInt32::operator/ ( const UInt32 value )
{
	return UInt32(this->_internalUInt32 / value._internalUInt32);
}
UInt32 UInt32::operator/ ( const int& value )
{
	return UInt32(this->_internalUInt32 / value);
}

//----------------------------------------------------------------------------
// %
UInt32 UInt32::operator% ( const UInt32 value )
{
	return UInt32(this->_internalUInt32 % value._internalUInt32);
}